home *** CD-ROM | disk | FTP | other *** search
/ APDL Eductation Resources / APDL Eductation Resources.iso / programs / electronic / rlab / TestMatrix / kms_r < prev    next >
Encoding:
Text File  |  1994-12-20  |  1.4 KB  |  50 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. // Synopsis:    Kac-Murdock-Szego Toeplitz matrix.
  4.  
  5. // Syntax:    A = kms ( N , RHO )
  6.  
  7. // Description:
  8.  
  9. //    A is the N-by-N Kac-Murdock-Szego Toeplitz matrix with 
  10. //    A[i;j] = RHO^(ABS((i-j))) (for real RHO).
  11.  
  12. //    If RHO is complex, then the same formula holds except that
  13. //    elements below the diagonal are conjugated. RHO defaults to
  14. //    0.5.
  15.  
  16. //      Properties:
  17. //         A has an LDL' factorization with
  18. //                  L = INV(TRIW(N,-RHO,1)'),
  19. //                  D[i;i] = (1-ABS(RHO)^2)*EYE(N,N) except D[1;1] = 1.
  20. //         A is positive definite if and only if 0 < ABS(RHO) < 1.
  21. //         INV(A) is tridiagonal.
  22.  
  23. //       Reference:
  24. //       W.F. Trench, Numerical solution of the eigenvalue problem
  25. //       for Hermitian Toeplitz matrices, SIAM J. Matrix Analysis and Appl.,
  26. //       10 (1989), pp. 135-146 (and see the references therein).
  27.  
  28. //    This file is a translation of kms.m from version 2.0 of
  29. //    "The Test Matrix Toolbox for Matlab", described in Numerical
  30. //    Analysis Report No. 237, December 1993, by N. J. Higham.
  31.  
  32. //-------------------------------------------------------------------//
  33.  
  34. kms = function ( n , rho )
  35. {
  36.   local (n, rho)
  37.  
  38.   if (!exist (rho)) { rho = 0.5; }
  39.  
  40.   A = (1:n)'*ones(1,n);
  41.   A = abs(A - A');
  42.   A = rho .^ A;
  43.   if (imag(rho))
  44.   {
  45.     A = conj(tril(A,-1)) + triu(A);
  46.   }
  47.  
  48.   return A;
  49. };
  50.